package com.qmhl.toolposition.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.qmhl.toolposition.fragment.AppHomeFragment
import com.qmhl.toolposition.fragment.AppMessageFragment
import com.qmhl.toolposition.fragment.AppMineFragment
import com.qmhl.toolposition.fragment.AppPositionFragment
import org.jetbrains.annotations.Nullable

class MainAdapter(private val fragmentActivity: FragmentActivity, private val count: Int) :
    FragmentStateAdapter(fragmentActivity) {

    override fun getItemCount(): Int {
        return count
    }

    override fun createFragment(position: Int): Fragment {
        return when (position) {
            0 -> AppHomeFragment()
            1 -> AppPositionFragment()
            2 -> AppMessageFragment()
            3 -> AppMineFragment()
            else -> AppHomeFragment()
        }
    }
}